// ThreadCloseWindowsList.cpp: implementation of the CThreadCloseWindowsList class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "aremoteserver.h"
#include "ThreadCloseWindowsList.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CThreadCloseWindowsList::CThreadCloseWindowsList()
{
	m_WindowsListIsOpen = FALSE;
}

CThreadCloseWindowsList::~CThreadCloseWindowsList()
{

}

BOOL CThreadCloseWindowsList::Start()
{
	if (!m_WindowsListIsOpen)
	{
		m_Handle = AfxBeginThread((AFX_THREADPROC)CloseWindowsListProc, this);
		if (m_Handle)
			m_WindowsListIsOpen = TRUE;
		else
			return false;
	}
	m_CloseWindowsListDelayTime = CLOSEWINDOWSLIST_DELAYTIME;
}

DWORD WINAPI CThreadCloseWindowsList::CloseWindowsListProc(LPVOID lpParameter)
{
	CThreadCloseWindowsList* pThreadData = (CThreadCloseWindowsList*)lpParameter;
	while (pThreadData->m_CloseWindowsListDelayTime > 0)
	{
		Sleep(1000);
		pThreadData->m_CloseWindowsListDelayTime --;
	}
	pThreadData->m_WindowsListIsOpen = FALSE;
	keybd_event(VK_MENU,   MapVirtualKey(   VK_MENU,   0   ),   KEYEVENTF_KEYUP   ,0);   	
	return 0;
}